package com.ruoyi.system.service.impl;



import com.ruoyi.common.core.domain.entity.DocFileManage;
import com.ruoyi.system.domain.vo.FileVo;
import com.ruoyi.system.mapper.DocFileMapper;
import com.ruoyi.system.mapper.SysInformationMapper;
import com.ruoyi.system.service.DocFileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
@Service
public class DocFileServiceImpl implements DocFileService {

    @Autowired
    private DocFileMapper DocFileMapper;

    @Autowired
    private SysInformationMapper sysInformationMapper;


    /***
     * 获取项目文档列表信息
     * @param file
     * @return
     */
    @Override
    public List<FileVo> selectProList(DocFileManage file) {
//        SecurityUtils.getLoginUser().getUser()
        List<FileVo> ruturnList = DocFileMapper.selectProList(file);
        //单独查出来部门
        List<FileVo> deptNameList = DocFileMapper.selectDeptName(file);
        for (DocFileManage docFileManage : deptNameList ){
            for (FileVo fileVo : ruturnList){
                fileVo.setDocDept(docFileManage.getDeptName());
            }
        }
        return ruturnList;
    }

    /***
     * 新增项目文档信息
     * @param file
     * @return
     */
    @Override
    public int insertPro(DocFileManage file) {
        Date date = new Date();
        file.setUploadTime(date);
        return DocFileMapper.insertPro(file);
    }

    /***
     * 修改项目文档信息
     * @param file
     * @return
     */
    @Override
    public int updateConfig(DocFileManage file) {
        return DocFileMapper.updateConfig(file);
    }

    /***
     * 逻辑删除项目文档信息
     * @param id
     * @return
     */
    @Override
    public int deleteById(Long[] id) {
        return DocFileMapper.deleteById(id);
    }



}
